home *** CD-ROM | disk | FTP | other *** search
- // Externs and protos for the simple Hash routines.
- //
- // 17-Feb-97 LR - modified to use typedefs, easier to read!
- // 29-May-95 KBI - created
- //
- /////////////////////
-
- #ifndef _H_HASH
- #define _H_HASH
-
- // Stuff specific to Hash table handling
-
- typedef char *cPtr;
-
- typedef unsigned long HashEntryType;
- typedef unsigned long HashValueType;
- typedef unsigned int StringIdxType;
-
- typedef HashEntryType *HashEntryPtr;
- typedef HashValueType *HashValuePtr;
- typedef StringIdxType *StringIdxPtr;
-
- #define HASH_ENTRY_SIZE sizeof( HashEntryType )
- #define HASH_VALUE_SIZE sizeof( HashValueType )
- #define STRING_INDEX_SIZE sizeof( StringIdxType )
-
- #define AVG_STRING_SIZE (20) // calc initial string space
- #define GROW_SPACE_CHUNK (1024L) // and grow it as needed in 1K chunks
-
- // globals - now created/carried in a handle on the fly
-
- typedef struct
- {
- unsigned int gSS_Size; // tracks current String Space Size
- unsigned int gNextString; // where to place the next string in the string space
- unsigned int gTotalNames; // tracks current # of entries in tbl
- unsigned int gMaxEntries; // max hash entries for this table
- Handle gNameTable; // The hashed values of the names
- Handle gValueTable; // A value is associated w/each name
- Handle gStringTable; // Table of indexes into the string space
- Handle gStringSpace; // the actual strings used for compares
-
- } HashTableGlobals, *HashTablePtr, **HashTableHandle;
-
- HashEntryType hash_Calc( char *name );
- HashTableHandle hash_New( int tableSize );
- void hash_Dispose( HashTableHandle table );
- int hash_Match( HashTableHandle table, char *name );
- OSErr hash_Add( HashTableHandle table, char *name, HashValueType value );
- Boolean hash_Search( HashTableHandle table, char *name, HashValueType *value );
- void hash_Clear( HashTableHandle table );
- OSErr hash_Update( HashTableHandle table, char *name, HashValueType value );
- OSErr hash_DisposeHandles( HashTableHandle table );
-
- #endif
-